package demo4;

public class ThreadSchedulingExample {
    static class MyThread extends Thread {
        private int sleepTime;

        public MyThread(int sleepTime) {
            this.sleepTime = sleepTime;
        }

        @Override
        public void run() {
            try {
                Thread.sleep(sleepTime);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("Thread " + getName() + " is running");
        }
    }

    public static void main(String[] args) {
        MyThread thread1 = new MyThread(2000);
        MyThread thread2 = new MyThread(1000);

        thread1.start();
        thread2.start();
    }
}